<template>
  <swiper :options="swiperOption" class="swiperCom" v-if="imgs.length">
      <swiper-slide  v-for="(item,i) in imgs" :key="i" class="swiper-container" @click="genIndex(i)">
        <img :src="item.pic" >
      </swiper-slide>
  </swiper>
  <div class="swiper-pagination"></div>
</template>
<script>
import { getBanner } from '@/api/index'
export default {
  data () {
    return {
      imgs: [],
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true,
        autoplay: 1000
      }
    }
  },
  async mounted () {
    const res = await getBanner(1)
    this.imgs = res.data.banners
    this.imgs.pop()
    // console.log(this.imgs)
  },
  methods: {
    genIndex (i) {
      //    console.log(i)
    }
  }
}
</script>
<style lang="less">
.swiperCom{
  width: 7.5rem;
  .swiper-container{
    padding: 0 0.2rem;
      img{
        height: 2.7rem;
        width: 7.1rem;
        border-radius: 0.2rem;
      }
  }
}
.swiper-pagination{
  position:absolute;
  left: 1.6rem;
  top: 3rem;
}
.swiper-pagination-bullet{
  margin-left: 0.2rem;
}
</style>
